{% extends 'admin/common/base.html' %}
{% block body %}

<body class="gray-bg">
    <div class="container-div">
        <div class="row">
            <div class="col-sm-12 search-collapse">
                <form id="role-form">
                    <input type="hidden" name="user_type" value="{{request.values.get('user_type')}}">
                    <div class="select-list">
                        <ul>
                            <li>
                                姓名：<input type="text" name="user" />
                            </li>
                            <li>
                                登录名称：<input type="text" name="username" />
                            </li>
                            <li>
                                手机号码：<input type="text" name="mobile" />
                            </li>
                            <li>
                                <a class="btn btn-primary btn-rounded btn-sm" onclick="$.table.search()"><i
                                        class="fa fa-search"></i>&nbsp;搜索</a>
                                <a class="btn btn-warning btn-rounded btn-sm" onclick="$.form.reset()"><i
                                        class="fa fa-refresh"></i>&nbsp;重置</a>
                            </li>
                        </ul>
                    </div>
                </form>
            </div>

            <div class="btn-group-sm" id="toolbar" role="group">
            </div>

            <div class="col-sm-12 select-table table-striped">
                <table id="bootstrap-table"></table>
            </div>
        </div>
    </div>
</body>
{% endblock %}
{% block js %}
{{ super() }}
<script>
    var sys_user_type_datas = {{ get_dict_data('sys_user_type') | tojson | safe}};
    $(function () {
        var options = {
            showSearch: false,
            showRefresh: false,
            showToggle: false,
            showColumns: false,
            clickToSelect: true,
            url: "{{url_for('admin.sys.user.list')}}",
            modalName: "用户",
            columns: [
            {
                {% if request.values.get('type') == 'one' %}
                radio: true
                {% else %} 
                checkbox: true
                {% endif %}
            },
            {
                field: 'id',
                title: '用户ID'
            },
            {
                field: 'username',
                title: '登录名称',
                sortable: true
            },
            {
                field: 'name',
                title: '用户名称'
            },
            {
                field: 'email',
                title: '邮箱',
                visible: false
            },
            {
                field: 'mobile',
                title: '手机'
            },
            {
                field: 'user_type',
                title: '用户类型',
                formatter: function (value, row, index) {
                    return $.table.selectDictLabel(sys_user_type_datas, value);
                }
            },
            {
                field: 'org.name',
                title: '部门'
            },
            {
                field: 'ctime',
                title: '创建时间',
                sortable: true
            }]
        };
        $.table.init(options);
    });

    function getSelections() {
        var selectedRows = $("#bootstrap-table").bootstrapTable('getSelections');
        return selectedRows;
	}

</script>
{% endblock %}